package com.ui.data
{
	import flash.geom.Rectangle;

	import com.net.AssetData;
	import com.ui.core.UIComponentData;
	import com.ui.skin.SkinStyle;

	/**
	 * @version 20091215
	 * @author Cafe
	 */
	public class ScrollBarData extends UIComponentData
	{
		public static const VERTICAL:int = 0;
		public static const HORIZONTAL:int = 1;
		public var trackAsset:AssetData = new AssetData( SkinStyle.scrollBar_trackSkin );
		public var thumbButtonData:ButtonData;
		public var upButtonData:ButtonData;
		public var downButtonData:ButtonData;
		public var direction:int = VERTICAL;
		public var wheelSpeed:int = 2;
		public var padding:int = 0;

		override protected function parse( source:* ):void
		{
			super.parse( source );
			var data:ScrollBarData = source as ScrollBarData;
			if (data == null) return;
			data.trackAsset = trackAsset;
			data.thumbButtonData = (thumbButtonData ? thumbButtonData.clone() : null);
			data.direction = direction;
			data.downButtonData = downButtonData;
			data.upButtonData = upButtonData;
			data.wheelSpeed = wheelSpeed;
			data.padding = padding;
		}

		public function ScrollBarData()
		{
			thumbButtonData = new ButtonData();
			thumbButtonData.x = 2;
			var inner:Rectangle = new Rectangle( 3, 5, 6, 20 );

			var assetData:AssetData = new AssetData( "thumb_up_bmd" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			thumbButtonData.downAsset = thumbButtonData.upAsset = assetData;
			assetData = new AssetData( "thumb_over_bmd" );
			assetData.isScaleBitmap = true;
			assetData.inner = inner;
			thumbButtonData.overAsset = assetData;
			thumbButtonData.disabledAsset = null;
			
			upButtonData = new ButtonData();
			upButtonData.x = 1;
			upButtonData.upAsset = new AssetData( SkinStyle.scrollBar_upUpSkin );
			upButtonData.overAsset = new AssetData( SkinStyle.scrollBar_upOverSkin );
			upButtonData.downAsset = new AssetData( SkinStyle.scrollBar_upDownSkin );
			downButtonData = new ButtonData();
			downButtonData.x = 1;
			downButtonData.upAsset = new AssetData( SkinStyle.scrollBar_bottomUpSkin );
			downButtonData.overAsset = new AssetData( SkinStyle.scrollBar_bottomOverSkin );
			downButtonData.downAsset = new AssetData( SkinStyle.scrollBar_bottomDownSkin );
			upButtonData.width = 13;
			upButtonData.height = 20;
			downButtonData.width = 13;
			downButtonData.height = 17;
			width = 10;
			height = 100;
		}

		override public function clone():*
		{
			var data:ScrollBarData = new ScrollBarData();
			parse( data );
			return data;
		}
	}
}
